<%@page import="org.swim.web.utils.SwimConst"%>
<%@page import="org.swim.web.utils.SwimUtils"%>
<%@page import="org.swim.remote.entities.IFeedback"%>
<%@page import="org.swim.remote.entities.IMessage"%>
<%@page import="org.swim.remote.entities.IFriendship"%>
<%@page import="org.swim.remote.entities.INotification"%>
<%@page import="org.swim.remote.entities.ICollaboration"%>
<%@page import="org.swim.web.servlet.consts.Action"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	List notifications = (List)request.getAttribute("notifications");
	IMessage mexx;
	IFriendship fsp;
	IFeedback fbk;
	for (int i = 0; i < notifications.size(); i++) {
		INotification notification = (INotification) notifications
				.get(i);
%>
<%
	if (notification instanceof IFriendship) {
			fsp = (IFriendship) notification;
%>
<div class="alert fade in" id="test" data-ts="<%= notification.getTimestamp().getTime()%>">
	<!-- <button type="button" class="close" data-dismiss="alert">&times;</button> -->
	<h5 class="alert-heading">New friendship</h5>
	<p><%=SwimUtils.getName(fsp.getUserBySenderId())%>
		wants to be your friend.
	</p>
	<p>
		<span class="btn-group"> <a class="btn btn-small btn-success"
			href="<%=SwimConst.Url.Servlet.PROFILE%>?a=<%=Action.ACCEPTFRIENDSHIP%>&friendshipId=<%=fsp.getId()%>">Accept</a>
			<a class="btn btn-small btn-danger"
			href="<%=SwimConst.Url.Servlet.PROFILE%>?a=<%=Action.REJECTFRIENDSHIP%>&friendshipId=<%=fsp.getId()%>">Reject</a>
		</span>
		<a href="<%=SwimConst.Url.Servlet.PROFILE%>?who=<%= fsp.getUserBySenderId().getId()%>" class="btn btn-small btn-primary">View profile</a>
	</p>
</div>
<%
	} else if (notification instanceof IMessage) {
			mexx = (IMessage) notification;
			if (mexx.getCollaboration().getStatus() == ICollaboration.Status.REQUESTED
					&& mexx.getCollaboration().getMessagesList().size() == 1) {
%><div class="alert fade in" id="test" data-ts="<%= notification.getTimestamp().getTime()%>">
	<!-- <button type="button" class="close" data-dismiss="alert">&times;</button> -->
	<h5 class="alert-heading">New collaboration</h5>
	<p><%=SwimUtils.getName(mexx.getIUserBySenderId())%>
		wants to collaborate with you.
	</p>
	<p>
		<span class="btn-group"> <a class="btn btn-small btn-success"
			href="<%=SwimConst.Url.Servlet.COLLABORATION%>?a=<%=Action.ACCEPTCOLLABORATION%>&collaborationId=<%=mexx.getCollaboration().getId()%>">Accept</a>
			<a class="btn btn-small btn-danger"
			href="<%=SwimConst.Url.Servlet.COLLABORATION%>?a=<%=Action.REJECTCOLLABORATION%>&collaborationId=<%=mexx.getCollaboration().getId()%>">Reject</a>
		</span>
		<a class="btn btn-small btn-primary"
			href="<%=SwimConst.Url.Servlet.COLLABORATION%>?a=<%=Action.VIEWCOLLABORATION%>&id=<%=mexx.getCollaboration().getId()%>">View
			collaboration</a>
	</p>
</div>
<%
	} else {
%>
<div class="alert alert-info fade in" id="test" data-ts="<%= notification.getTimestamp().getTime()%>">
	<!-- <button type="button" class="close" data-dismiss="alert">&times;</button> -->
	<h5 class="alert-heading">New message</h5>
	<p><%=SwimUtils.getName(mexx.getIUserBySenderId())%>
		has a message for you.
	</p>
	<p>
		<a class="btn btn-small btn-info"
			href="<%=SwimConst.Url.Servlet.COLLABORATION%>?a=<%=Action.VIEWCOLLABORATION%>&id=<%=mexx.getCollaboration().getId()%>">View
			collaboration</a>
	</p>
</div>
<%
	}
%>
<%
	} else if (notification instanceof IFeedback) {
		fbk = (IFeedback) notification;
%>
<div class="alert alert-info fade in" id="test" data-ts="<%= notification.getTimestamp().getTime()%>">
	<!-- <button type="button" class="close" data-dismiss="alert">&times;</button> -->
	<h5 class="alert-heading">New feedback</h5>
	<p><%=SwimUtils.getName(fbk.getIUserBySenderId())%>
		send a feedback about you.
	</p>
	<p>
		<a class="btn btn-small btn-info"
			href="<%=SwimConst.Url.Servlet.COLLABORATION%>?a=<%=Action.VIEWCOLLABORATION%>&id=<%=fbk.getCollaboration().getId()%>">View
			collaboration</a>
	</p>
</div>
<%
	}
	}
%>